<script>
    let arr = [1,2,2,3,4,5,5,6,7,8]
   
    quhcong2(arr)

    function quhcong2(array){
        let newarr = []
        for(let i=0;i<array.length;i++){
            if(newarr.indexOf(array[i]) === -1){
                newarr.push(array[i])
            }
        }
        console.log('??', newarr)

        return newarr
    }


    let res = new Set([...arr])

    console.log('res', res)


    

    function quchong(array){
        let newarr = []
        let obj = {}
        for(let i =0;i<array.length;i++){
            if(!obj[array[i]]){
                obj[array[i]] = 1
                newarr.push(array[i])
            }else{
                obj[array[i]]++
            }
        }
        console.log('obj', obj)
        console.log('newarr', newarr)
        return newarr

    }
    quchong(arr)


   
</script>